'use strict';

module.exports = app => {
  const { router, controller: { device }, middleware: { validator, checkPageTable, checkParams } } = app;

  const baseUrl = '/api/device';
  router.get(baseUrl + '/all', device.all);
  router.get(baseUrl + '/top', device.top);
  router.get(baseUrl, checkPageTable(), device.index);
  router.get(baseUrl + '/:id', checkParams(), device.show);
  router.post(baseUrl, validator('device.create'), device.create);
  router.put(baseUrl + '/:id', checkParams(), validator('device.update'), device.update);
  router.delete(baseUrl + '/:id', checkParams(), device.destroy);
};
